Skip to main content

sm.scrapcomputers.config

sm.scrapcomputers.config Lets you configure the mod's world settings. Like setting config values or creating new configurations.

Fields

TypeNameDescription
stringkeyThe key used in sm.storage. Use this if you want to access ScrapComputer's Configuration Data directly.

Structures

Configuration

A configuration for ScrapComputers.

Fields:

  • id [ string ] The id of the config. Reccommended to be in this format to not cause any conflicts: [MOD_NAME].[COMPONENT_NAME].[CONFIG_NAME]
  • name [ string ] The name of the config
  • description [ string ] The description of the config
  • selectedOption [ integer ] The current config's selected option
  • hostOnly [ boolean ] If the configuration is host only accessable
  • options [ string[] ] List of usable options for the config.

Functions

createDefaultConfigs

sm.scrapcomputers.config.createDefaultConfigs( onlyDefaultConfigs )

Creates default configurations and returns it

Arguments:

  • onlyDefaultConfigs [ boolean? ] If true, it will only return default configs without the addon parts. Default is false

Returns:


initConfig

sm.scrapcomputers.config.initConfig()

Server-Only

Initalizes the Config system. You generally don't have to call this as it gets called when ScrapComputers loads


nameToId

sm.scrapcomputers.config.nameToId( name )

Server-Only

Converts a name to a id

Arguments:

  • name [ string ] The name of the config

Returns:

  • [ string? ] The id of the config

getConfigByIndex

sm.scrapcomputers.config.getConfigByIndex( index )

Server-Only

Gets a configuration by index (not id!) Will error if not found.

Arguments:

  • index [ integer ] The index to search

Returns:


getTotalConfigurations

sm.scrapcomputers.config.getTotalConfigurations()

Server-Only

Gets the total configurations and returns it

Returns:

  • [ integer ] The amount of configurations

setConfig

sm.scrapcomputers.config.setConfig( id, selectedOption )

Server-Only
Configuration Initalization Required

Sets a config's current selected option

Arguments:

  • id [ string ] The id of the config
  • selectedOption [ integer ] The new selected option

resetConfiguration

sm.scrapcomputers.config.resetConfiguration()

Server-Only
Configuration Initalization Required

Resets the configurations to its defaults


saveConfig

sm.scrapcomputers.config.saveConfig()

Server-Only
Configuration Initalization Required

Saves the current configurations to the world


createConfig

sm.scrapcomputers.config.createConfig( id, name, description, hostOnly, options )

Server-Only
Configuration Initalization Required

Creates a new config.

Arguments:

  • id [ string ] The id of the config. Reccommended to be in this format to not cause any conflicts: [MOD_NAME].[COMPONENT_NAME].[CONFIG_NAME]
  • name [ string ] The name of the configuration
  • description [ string ] The description of the config
  • hostOnly [ boolean ] If it is only acceessable by the host or not
  • options [ string[] ] The options the configuration has

getConfig

sm.scrapcomputers.config.getConfig( id )

Server-Only

Gets a configuration by id Will error if not found.

Arguments:

  • id [ string ] The ID of the config

Returns:


configExists

sm.scrapcomputers.config.configExists( id )

Server-Only

Returns true if a configuration existed via ID

Arguments:

  • id [ string ] The ID of the configuration

Returns:

  • [ boolean ] If the configuration existed or not